package com.example.raspberry_pi_demob.service;

import com.example.raspberry_pi_demob.DAO.AllDataDAO;
import com.example.raspberry_pi_demob.entity.AllData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AllDataService {
    @Autowired
    AllDataDAO allDataDAO;
    public List<AllData> findAllDataList() {
        return allDataDAO.selectAll();
    }

    public AllData findAllDataByTimestamp(Integer timestamp) {
        return allDataDAO.selectByPrimaryKey(timestamp);
    }

    public AllData findAllDataByMacAddress(String macAddress) {
        return allDataDAO.selectByMacAddress(macAddress);

    }


    //需要用到sql的where 大于小于
    public List<AllData> findAllDataByTimeBucket(String startTime, String endTime) {
        return allDataDAO.selectByTimeBucket(startTime,endTime);
    }

    public int delete(Integer timestamp) {
        return allDataDAO.deleteByPrimaryKey(timestamp);
    }


    public int update(Integer timestamp, AllData allData) {
        return allDataDAO.updateByPrimaryKey(timestamp,allData);
    }

    public int save(AllData allData) {
        return allDataDAO.insert(allData);
    }

}
